package net.thread;

import java.io.File;
import java.io.FileInputStream;
import java.security.DigestInputStream;
import java.security.MessageDigest;

public class ReturnDigest extends Thread
{
	private File input;
	private byte[] digest;
	public ReturnDigest(File input)
	{
		this.input = input;
	}
	@Override
	public void run()
	{
		try
		{
			FileInputStream in = new FileInputStream(input);
			MessageDigest sha = MessageDigest.getInstance("SHA");
			DigestInputStream din = new DigestInputStream(in, sha);
			@SuppressWarnings("unused")
			int b;
			while ((b=din.read())!=-1)
			{
				din.close();
			}
			digest = sha.digest();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
	public byte[] getDigest()
	{
		return digest;
	}
}
